<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<body>
<table width="100%"  style="font-size: 23px;padding: 0;text-align: center;">
	<tr><td style="text-align:center">Users Detail</td></tr>
</table>

<s:form action="updateUser" method="post" onsubmit="return validatePassword(password,confirmPassword);">
<s:iterator value="user">
<table>
<tr><td width="30%"><b>Profile :</b>
<s:hidden name="uuid"></s:hidden>
<s:textfield name="usertype" label="User Type" readonly="true"/>
<s:textfield name="status" label="Online" />
<s:textfield name="title" label="Title" />
<s:textfield name="firstname" label="First Name" />
<s:textfield name="lastname" label="Last Name" />
<s:textfield name="emailId" label="UserId/EmailId" readonly="true"/>
<s:radio name="gender" label="Gender" list="#{'m':'Male','f':'Female'}" />
<s:textfield name="companyname" label="Companyname" />
<s:password name="password" value="%{basiccredential.password}" label="Password" />
<s:password name="confirmPassword" value="%{basiccredential.passwordreminder}" label="Confirm Password" />
</td>
<td width="35%">
<b>Current Address :</b>
<s:textfield name="ca_addressLine1" label="Address Line1" value="%{currentAddress.addressLine1}"/>
<s:textfield name="ca_addressLine2" label="Address Line2" value="%{currentAddress.addressLine2}"/>
<s:textfield name="ca_cityName" label="City" value="%{currentAddress.City.cityName}"/>
<s:textfield name="ca_continent" label="Continent" value="%{currentAddress.Continent.name}"/>
<s:textfield name="ca_countryName" label="Country" value="%{currentAddress.Country.countryName}"/>
<s:textfield name="ca_region" label="Region" value="%{currentAddress.Region.name}"/>
<s:textfield name="ca_stateName" label="State" value="%{currentAddress.State.stateName}"/>
<s:textfield name="ca_phone" label="Phone" value="%{currentAddress.phone}"/>
<s:textfield name="ca_phonebusiness" label="Phone Business" value="%{currentAddress.phonebusiness}"/>
<s:textfield name="ca_mobile" label="Mobile" value="%{currentAddress.mobile}"/>
<s:textfield name="ca_postalcode" label="Postal Code" value="%{currentAddress.postalcode}"/>
</td>
<td width="35%">
<b>Permanent Address :</b>
<s:textfield name="pa_addressLine1" label="Address Line1" value="%{permanentAddress.addressLine1}"/>
<s:textfield name="pa_addressLine2" label="Address Line2" value="%{permanentAddress.addressLine2}"/>
<s:textfield name="pa_cityName" label="City" value="%{permanentAddress.City.cityName}"/>
<s:textfield name="pa_continent" label="Continent" value="%{permanentAddress.Continent.name}"/>
<s:textfield name="pa_countryName" label="Country" value="%{permanentAddress.Country.countryName}"/>
<s:textfield name="pa_region" label="Region" value="%{permanentAddress.Region.name}"/>
<s:textfield name="pa_stateName" label="State" value="%{permanentAddress.State.stateName}"/>
<s:textfield name="pa_phone" label="Phone" value="%{permanentAddress.phone}"/>
<s:textfield name="pa_phonebusiness" label="Phone Business" value="%{permanentAddress.phonebusiness}"/>
<s:textfield name="pa_mobile" label="Mobile" value="%{permanentAddress.mobile}"/>
<s:textfield name="pa_postalcode" label="Postal Code" value="%{permanentAddress.postalcode}"/>
</td></tr>
<s:submit value="UpdateProfile" align="center" />
</table>
</s:iterator>
</s:form>
</body>
<script type="text/javascript">
function validatePassword(password,confirmPassword) {
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if ((password.value == "")) {
    	password.style.background = 'Yellow';
    	alert("You didn't enter a password.");
    	 return false;        
    } else if ((password.value.length < 7) || (password.value.length > 15)) {
    	alert("The password is the wrong length.It should be 7-15 word.");
        password.style.background = 'Yellow';
        return false;
    } else if (illegalChars.test(password.value)) {
    	alert("The password contains illegal characters.");
        password.style.background = 'Yellow';
        return false;
    } else if (!((password.value.search(/(a-z)+/)) && (password.value.search(/(0-9)+/)))) {
    	alert("The password must contain at least one numeral.");
        password.style.background = 'Yellow';
        return false;
    }else if (password.value != confirmPassword.value) { 
    	   alert("Your password and confirmation password do not match.");
    	   confirmPassword.style.background = 'Yellow';
    	   return false; 
    	}
    else {
    	password.style.background = 'White';
    	 return true;
    }
}   
</script>

</html>
